// 首页
// http://m8.haodanpai.com:802/

// 登录
// http://m8.haodanpai.com:802/#/tabs/login

// 接单
// http://m8.haodanpai.com:802/Task/GetTaskList



let token = Android.getMap("token")
document.cookie = token



// 请求数据
function getParameterHandler() {
    let headers = {
        "cookie": parameter.getMap("token")
    }
    let body = {
        "PageIndex": 1,
        "PageSize": 10,
        "State": 1,
        "loading": true,
        "isAjax": true
    }
    let strUrl = ``
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "POST",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()


// 处理返回数据

function getResponse() {
    let res = response.getMap("res")
    let code = "500"
    let message = "接单中"
    let dataKey = ""
    let dataValue = ""

    try {
        res = JSON.parse(res)
        if (res["Code"] == 0 && res["Data"]["totalPage"] > 0) {
            code = "200"
            message = "接单成功，请尽快完成"
        } else {
            code = "500"
            message = "接单中"
        }
    } catch (e) {
        code = "300"
        message = "请求服务失败"
    }


    return {
        code: code,
        message: message,
        dataKey: dataKey,
        dataValue: dataValue
    }
}
getResponse()


// { "Success": true, "Data": { "totalPage": 0, "data": [] }, "Code": 1, "Message": "获取成功" }